from django import template
from django.urls import reverse
from django.http.request import QueryDict
register=template.Library()
@register.simple_tag
def reverse_url(request,name,*args,**kwargs):
    #获取当前的路径
    next = request.get_full_path()
    # print(next)
    url=reverse(name,args=args,kwargs=kwargs)
    qb = QueryDict(mutable=True)  #可编辑的
    qb[next] = next
    return_url = "{}?{}".format(url, qb.urlencode())  #获取url地址 编辑完后返回编辑后的页面
    return return_url

